<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>hello</title>
</head>
<body>
<div th:insert="~{head::headDiv}"></div>


hello : <div th:text="${username}">将被替换掉的原始值</div>
hello : <div th:text="${username1}">不能识别文本中的HTML标签</div>
hello : <div th:utext="${username1}">th:utext则可以实现html标签</div>

用户名:<input type="text" value="${username}">
用户名:<input type="text" th:value="${username}">
<br>

性别:
<input type="radio" th:checked="${sex==1}">男
<input type="radio" th:checked="${sex==2}">女
<br>
所在城市
<select>
    <option th:selected="${city=='广州'}">广州</option>
    <option th:selected="${city=='山东'}">山东</option>
    <option th:selected="${city=='岳阳'}">岳阳</option>
</select>

<h2>学习th遍历</h2>
用户列表如下：
<table border="1">
    <tr>
        <th>编号</th>
        <th>用户名</th>
        <th>密码</th>
    </tr>
    <tr th:each="user:${users}">
        <td th:text="${user.id}"></td>
        <td th:text="${user.username}"></td>
        <td th:text="${user.pass}"></td>
    </tr>
</table>
<br>

<div th:if="${username}==lhb" th:text="th的if判断true时生效"></div>
<div th:unless="${username}!=lhb" th:text="th的unless判断false时生效"></div>

当前时间:<span th:text="${#dates.format(date,'yyyy-MM-dd HH:mm:ss')}"></span>
<br><br><br>

<h2>前端请求后台</h2>
<a th:href="@{/thymeleaf/login}">向后端发请求用@{请求路径}</a><br>
<a th:href="@{https://www.baidu.com}">也可以跳转网页 如“百度”</a><br>
<a th:href="@{/thymeleaf/login(username='lhb')}">也可以向后端传值</a><br>

<form th:action="@{/thymeleaf/login}" method="get">
    账号:<input type="text" name="username">
    密码:<input type="text" name="pass">
    <input type="submit" value="登录">
</form>
</body>
</html>